package com.uzai.console.web.pyq;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.common.enums.DeviceTypeEnum;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.pyq.pyqcontenttemplate.PyqContentTemplateDto;
import com.uzai.console.dto.pyq.pyqcontenttemplate.PyqContentTemplateIdDto;
import com.uzai.console.dto.pyq.pyqcontenttemplate.PyqContentTemplateQuery;
import com.uzai.console.entity.PyqContentTemplate;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.mapper.PyqContentTemplateMapper;
import com.uzai.console.service.pyq.PyqContentTemplateService;
import com.uzai.console.vo.base.SelectKeyVo;
import com.uzai.console.vo.pyq.pyqcontenttemplate.PyqContentTemplateVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


/**
 * 内容模板
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "内容模板",tags = "个人微信|朋友圈|内容模板")
@ApiSort(30)
@RestController
public class PyqContentTemplateController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(PyqContentTemplateController.class);

    @Autowired
    private PyqContentTemplateService pyqContentTemplateService;
    @Autowired
    private PyqContentTemplateMapper pyqContentTemplateMapper;

    @ApiOperation(value = "分页查询内容模板列表", notes = "分页查询内容模板列表", response = PyqContentTemplateVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/pyqContentTemplate/findPyqContentTemplateList")
    public Object findPyqContentTemplateList(@RequestBody PyqContentTemplateQuery pyqContentTemplateQuery){
        pyqContentTemplateQuery.setDeviceType(DeviceTypeEnum.DT_PC_WECHAT.getKey());
        return pyqContentTemplateService.findPyqContentTemplateList(pyqContentTemplateQuery);
    }

    @SystemLogType(model = SystemModelEnum.PyqContentTemplate, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加内容模板", notes = "添加内容模板")
    @ApiOperationSupport(order = 2)
    @PostMapping("/pyqContentTemplate/addPyqContentTemplate")
    public Object addPyqContentTemplate(@RequestBody PyqContentTemplateDto pyqContentTemplateDto){
        pyqContentTemplateService.addPyqContentTemplate(pyqContentTemplateDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqContentTemplate, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "编辑内容模板", notes = "编辑内容模板" )
    @ApiOperationSupport(order = 3)
    @PostMapping("/pyqContentTemplate/updatePyqContentTemplate")
    public Object updatePyqContentTemplate(@RequestBody PyqContentTemplateDto pyqContentTemplateDto){
        pyqContentTemplateService.updatePyqContentTemplate(pyqContentTemplateDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqContentTemplate, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除", notes = "删除")
    @ApiOperationSupport(order = 4)
    @PostMapping("/pyqContentTemplate/deletePyqContentTemplate")
    public Object deletePyqContentTemplate(@RequestBody PyqContentTemplateIdDto pyqContentTemplateIdDto){
        pyqContentTemplateService.deletePyqContentTemplate(pyqContentTemplateIdDto);
        return true;
    }

    @ApiOperation(value = "查询内容模板详情", notes = "查询内容模板详情", response = PyqContentTemplateVo.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/pyqContentTemplate/findPyqContentTemplate")
    public Object findPyqContentTemplate(@RequestBody PyqContentTemplateIdDto pyqContentTemplateIdDto){
        return pyqContentTemplateService.findPyqContentTemplate(pyqContentTemplateIdDto);
    }

    @ApiOperation(value = "查询所有内容模板下拉列表", notes = "查询所有内容模板下拉列表", response = PyqContentTemplateVo.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/pyqContentTemplate/findSelectList")
    public Object findSelectList(@RequestBody PyqContentTemplateQuery pyqContentTemplateQuery){
        pyqContentTemplateQuery.setDeviceType(DeviceTypeEnum.DT_PC_WECHAT.getKey());
        return pyqContentTemplateService.findSelectList(pyqContentTemplateQuery);
    }

}
